<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>现代化UI布局示例</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f5f5f5;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        h1, h2 {
            text-align: center;
            margin-bottom: 30px;
        }

        h1 {
            color: #2c3e50;
            font-size: 2.5em;
        }

        h2 {
            color: #34495e;
            border-bottom: 2px solid #3498db;
            padding-bottom: 10px;
            margin-top: 50px;
        }

        .layout-section {
            background: white;
            border-radius: 10px;
            padding: 30px;
            margin-bottom: 40px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        /* 1. Flexbox布局 */
        .flex-container {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
        }

        .flex-item {
            flex: 1;
            min-width: 200px;
            background: #3498db;
            color: white;
            padding: 20px;
            border-radius: 8px;
            text-align: center;
        }

        /* 2. CSS Grid布局 */
        .grid-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .grid-item {
            background: #e74c3c;
            color: white;
            padding: 20px;
            border-radius: 8px;
            text-align: center;
        }

        /* 3. 响应式布局 */
        .responsive-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }

        .responsive-item {
            background: #9b59b6;
            color: white;
            padding: 20px;
            border-radius: 8px;
        }

        /* 4. 卡片式布局 */
        .card-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 25px;
        }

        .card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            overflow: hidden;
            transition: transform 0.3s ease;
        }

        .card:hover {
            transform: translateY(-5px);
        }

        .card-img {
            height: 180px;
            background: #f39c12;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.2em;
        }

        .card-content {
            padding: 20px;
        }

        /* 5. 分屏布局 */
        .split-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            height: 300px;
        }

        .split-item {
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            color: white;
            font-size: 1.2em;
        }

        .split-left {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .split-right {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        /* 6. SPA布局 */
        .spa-container {
            display: grid;
            grid-template-rows: 60px 1fr;
            grid-template-columns: 200px 1fr;
            gap: 0;
            height: 300px;
        }

        .spa-header {
            grid-column: 1 / -1;
            background: #2c3e50;
            color: white;
            display: flex;
            align-items: center;
            padding: 0 20px;
        }

        .spa-sidebar {
            background: #34495e;
            color: white;
            padding: 20px;
        }

        .spa-content {
            background: #ecf0f1;
            padding: 20px;
            overflow-y: auto;
        }

        /* 7. 瀑布流布局 */
        .masonry-container {
            column-count: 3;
            column-gap: 20px;
        }

        .masonry-item {
            background: #1abc9c;
            color: white;
            margin-bottom: 20px;
            padding: 20px;
            border-radius: 8px;
            break-inside: avoid;
        }

        /* 8. 汉堡菜单布局 */
        .hamburger-container {
            position: relative;
        }

        .menu-toggle {
            display: none;
            background: #3498db;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 4px;
            cursor: pointer;
        }

        .hamburger-menu {
            display: flex;
            gap: 15px;
            list-style: none;
        }

        .hamburger-menu li {
            background: #95a5a6;
            color: white;
            padding: 10px 15px;
            border-radius: 4px;
        }

        /* 9. 全屏布局 */
        .fullscreen-container {
            height: 300px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            color: white;
            text-align: center;
        }

        .fullscreen-content h3 {
            font-size: 2em;
            margin-bottom: 15px;
        }

        /* 10. 不对称布局 */
        .asymmetric-container {
            display: grid;
            grid-template-columns: 1fr 2fr 1fr;
            grid-template-rows: 200px 100px;
            gap: 20px;
        }

        .asymmetric-item {
            background: #e67e22;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
        }

        .item-1 { grid-column: 1 / 3; grid-row: 1; }
        .item-2 { grid-column: 3; grid-row: 1 / 3; }
        .item-3 { grid-column: 1; grid-row: 2; }
        .item-4 { grid-column: 2; grid-row: 2; }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .split-container {
                grid-template-columns: 1fr;
                height: auto;
            }

            .spa-container {
                grid-template-columns: 1fr;
                grid-template-rows: 60px auto auto;
            }

            .spa-sidebar {
                grid-column: 1;
            }

            .spa-content {
                grid-column: 1;
            }

            .masonry-container {
                column-count: 1;
            }

            .menu-toggle {
                display: block;
                margin-bottom: 15px;
            }

            .hamburger-menu {
                display: none;
                flex-direction: column;
            }

            .hamburger-menu.active {
                display: flex;
            }

            .asymmetric-container {
                grid-template-columns: 1fr;
                grid-template-rows: auto;
            }

            .item-1, .item-2, .item-3, .item-4 {
                grid-column: 1;
                grid-row: auto;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>现代化UI布局示例</h1>
        
        <!-- 1. Flexbox布局 -->
        <div class="layout-section">
            <h2>1. Flexbox布局</h2>
            <div class="flex-container">
                <div class="flex-item">项目 1</div>
                <div class="flex-item">项目 2</div>
                <div class="flex-item">项目 3</div>
                <div class="flex-item">项目 4</div>
            </div>
        </div>

        <!-- 2. CSS Grid布局 -->
        <div class="layout-section">
            <h2>2. CSS Grid布局</h2>
            <div class="grid-container">
                <div class="grid-item">网格项 1</div>
                <div class="grid-item">网格项 2</div>
                <div class="grid-item">网格项 3</div>
                <div class="grid-item">网格项 4</div>
                <div class="grid-item">网格项 5</div>
                <div class="grid-item">网格项 6</div>
            </div>
        </div>

        <!-- 3. 响应式布局 -->
        <div class="layout-section">
            <h2>3. 响应式布局</h2>
            <div class="responsive-container">
                <div class="responsive-item">
                    <h3>响应式块 1</h3>
                    <p>这个布局会根据屏幕大小自动调整列数</p>
                </div>
                <div class="responsive-item">
                    <h3>响应式块 2</h3>
                    <p>在小屏幕上会变成单列布局</p>
                </div>
                <div class="responsive-item">
                    <h3>响应式块 3</h3>
                    <p>保持良好的可读性和用户体验</p>
                </div>
            </div>
        </div>

        <!-- 4. 卡片式布局 -->
        <div class="layout-section">
            <h2>4. 卡片式布局</h2>
            <div class="card-container">
                <div class="card">
                    <div class="card-img">图片区域</div>
                    <div class="card-content">
                        <h3>卡片标题</h3>
                        <p>这是卡片的内容描述，展示模块化设计的优势。</p>
                    </div>
                </div>
                <div class="card">
                    <div class="card-img">图片区域</div>
                    <div class="card-content">
                        <h3>卡片标题</h3>
                        <p>每张卡片都是独立的内容模块，易于管理和交互。</p>
                    </div>
                </div>
                <div class="card">
                    <div class="card-img">图片区域</div>
                    <div class="card-content">
                        <h3>卡片标题</h3>
                        <p>悬停效果增强了用户交互体验。</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 5. 分屏布局 -->
        <div class="layout-section">
            <h2>5. 分屏布局</h2>
            <div class="split-container">
                <div class="split-item split-left">左侧内容区域</div>
                <div class="split-item split-right">右侧内容区域</div>
            </div>
        </div>

        <!-- 6. SPA布局 -->
        <div class="layout-section">
            <h2>6. 单页应用布局</h2>
            <div class="spa-container">
                <div class="spa-header">应用头部导航</div>
                <div class="spa-sidebar">侧边栏菜单</div>
                <div class="spa-content">
                    <h3>主要内容区域</h3>
                    <p>这里是应用的主要内容显示区域，可以动态加载不同页面内容。</p>
                </div>
            </div>
        </div>

        <!-- 7. 瀑布流布局 -->
        <div class="layout-section">
            <h2>7. 瀑布流布局</h2>
            <div class="masonry-container">
                <div class="masonry-item">瀑布流项目 1<br>高度可变的内容</div>
                <div class="masonry-item">瀑布流项目 2<br>适应不同内容高度<br>创建自然的流动效果</div>
                <div class="masonry-item">瀑布流项目 3</div>
                <div class="masonry-item">瀑布流项目 4<br>非常适合图片或卡片展示</div>
                <div class="masonry-item">瀑布流项目 5<br>内容长度不一<br>依然保持美观布局</div>
                <div class="masonry-item">瀑布流项目 6</div>
            </div>
        </div>

        <!-- 8. 汉堡菜单布局 -->
        <div class="layout-section">
            <h2>8. 汉堡菜单布局</h2>
            <div class="hamburger-container">
                <button class="menu-toggle" onclick="toggleMenu()">☰ 菜单</button>
                <ul class="hamburger-menu" id="hamburgerMenu">
                    <li>首页</li>
                    <li>产品</li>
                    <li>服务</li>
                    <li>关于</li>
                    <li>联系</li>
                </ul>
            </div>
        </div>

        <!-- 9. 全屏布局 -->
        <div class="layout-section">
            <h2>9. 全屏布局</h2>
            <div class="fullscreen-container">
                <div class="fullscreen-content">
                    <h3>沉浸式体验</h3>
                    <p>全屏布局创造强烈的视觉冲击力</p>
                </div>
            </div>
        </div>

        <!-- 10. 不对称布局 -->
        <div class="layout-section">
            <h2>10. 不对称布局</h2>
            <div class="asymmetric-container">
                <div class="asymmetric-item item-1">大块区域 A</div>
                <div class="asymmetric-item item-2">侧边区域 B</div>
                <div class="asymmetric-item item-3">小块区域 C</div>
                <div class="asymmetric-item item-4">小块区域 D</div>
            </div>
        </div>
    </div>

    <script>
        function toggleMenu() {
            const menu = document.getElementById('hamburgerMenu');
            menu.classList.toggle('active');
        }

        // 为所有布局添加交互效果说明
        document.addEventListener('DOMContentLoaded', function() {
            const sections = document.querySelectorAll('.layout-section');
            
            sections.forEach(section => {
                const title = section.querySelector('h2');
                title.style.cursor = 'pointer';
                
                title.addEventListener('click', function() {
                    const content = section.querySelector('div:not(h2)');
                    content.style.display = content.style.display === 'none' ? 'block' : 'none';
                });
            });
        });
    </script>
</body>
</html>
